<?
// Page variables
$rightCol   = 1;
$parseURI   = 1;
$loggedUser = 0;
$myShop     = 0;
$ads        = 0;

include("includes/functions.php"); 

if ($_GET[send] == 1) {
	// Clean input
	$fullName  = emailPreventInjection(fieldToDB($fullName));
	$email     = emailPreventInjection(fieldToDB($email));
	$subject   = emailPreventInjection(fieldToDB($subject));
	$emailMessage = emailPreventInjection($message);
	$dbMessage = emailPreventInjection(fieldToDB($message));
	
	if ( empty($messageConcerns) || ($messageConcerns == "Select...") ) { $messageConcerns = null; }
	if ( empty($siteArea) || ($siteArea == "Select...") ) { $siteArea = null; }
	
	$sql = "INSERT into transContact (
			UID,
			Name,
			Email,
			MessageConcerns,
			SiteArea,
			Subject,
			Message,
			DateMessage
			) values (
			'".$_SESSION[UID]."',
			'$fullName',
			'$email',
			'$messageConcerns',
			'$siteArea',
			'$subject',
			'$dbMessage',
			'".date('Y-m-d')."'
			)";
	$result = mysql_db_query($dbname,$sql);
	
	// Send thank you message to submitter - some time in the future
	// We don't want to be sending too many messages
	
	// Send mail to Admin
	$message  = 'A TCN user has submitted a Contact form:';
	$message .= '
Name:             '.$fullName.'
Email Address:    '.$email.'
Message Concerns: '.$messageConcerns.'

---:: MESSAGE ::-----------------------------------------------
'.$emailMessage;
	
	$to = $masterMail;
	//$to = 'jdenton@quik.com';	
	mailNew($fullName, $email, $to, $subject, $message); 
	$sent = 1;
}

include("includes/header.php"); ?>
<Script Language="JavaScript">
<!-- 
function checkForm(form) {
	if (form.email.value == "") {
		alert("Please enter your email address.")
		return false		
	}	
	
	return true
} 
//-->
</script>

	<div id="pageTop"></div>
	<div id="pageContent">
		<? include("includes/menu_main.php"); ?>
		
		<div id="rightCol">
			<img src="images/rightColTop.gif">
			<? include("includes/rightCol.php");  ?>
		</div>
		
		<div id="mainContent">
			<h1>Contact Us</h1>
			
			<p class="margin">
			<? if ($sent == 1) { ?>
			<b><?=$fullName; ?>, your message has been sent.</b><br><br>
			
			Your comments and input help make the Transition Community Network a great
			online resource for everyone. We value your communication and thank you for
			contacting us.  We will make every effort to contact you shortly.<br><br> 
			
			<div class="spacer2"></div>
			<? } else { ?>
			Please complete the form below to contact the Transition Community Network and leave feedback,
			ask a question, report bugs or abuse or get some help. We will make every effort
			to reply soon if necessary.<br><br>
			
			If you prefer to use email, send a message to:<br />
			<b>General Inquiries:</b> <a href="mailto:<?=$masterMail; ?>"><?=$masterMail; ?></a><br />
			<b>Website Related Issues:</b> <a href="mailto:<?=$webmasterMail; ?>"><?=$webmasterMail; ?></a><br /><br />
			
			Thanks for contacting us!<br><br>
			
			<form action="<?=$PHP_SELF; ?>?send=1" method="POST" name="main" onSubmit="return checkForm(this)">
			<input type="hidden" name="date" value="<? echo date("Y-m-d"); ?>">
			<table border="0" width="100%" cellspacing="2">			
			<tr>
				<td bgcolor="#E8E8D7" width="50%" class="formText"><font color="#E8E8D7">&raquo;</font> Your Name</td>
				<td>&nbsp;<input type="text" name="fullName" style="width: 230px;" value="<?=$userName; ?>"></td>
			</tr>
			<tr>
				<td bgcolor="#E8E8D7" valign="top" class="formText"><font color="red">&raquo;</font> Email Address</td>
				<td class="text">&nbsp;<input type="text" style="width: 230px;" name="email" value="<?=$email; ?>">
				</td>
			</tr>
			<tr>
				<td bgcolor="#E8E8D7" valign="top" class="formText"><font color="#E8E8D7">&raquo;</font> My Message Concerns</td>
				<td class="text">&nbsp;<select name="messageConcerns" size="1" style="width: 230px;">
					<option>Select...</option>
					<option></option>
					<option value="General Info">General Info</option>
					<option value="New Feature Request"
					<? if ($_GET[fr] == 1) { echo " selected "; } ?>
					>New Feature Request</option>
					<option value="Help">HELP!</option>
					<option value="Bug Reporting">Bug Reporting</option>
					<option value="Abuse Reporting">Abuse Reporting</option>
					<option value="None">None of the above</option>
					</select>
				</td>
			</tr>
			<tr>
				<td bgcolor="#E8E8D7" valign="top" class="formText"><font color="#E8E8D7">&raquo;</font> Which Site Area</td>
				<td class="text">&nbsp;<select name="siteArea" size="1" style="width: 230px;">
					<option>Select...</option>
					<option></option>
					<option value="Adding a Resource">Adding a Resource</option>
					<option value="Ranking Resources">Ranking Resources</option>
					<option value="Searching for Resources">Searching for Resources</option>
					<option value="None of the Above">None of the above</option>
					</select>
				</td>
			</tr>
			</table>
			<table border="0" cellspacing="2" cellpadding="3">			
			<tr>
				<td bgcolor="#E8E8D7" width="100%" class="formText">Subject and Message</td>
			</tr>
			<tr>
				<td><input type="text" name="subject" style="width: 390;" value="Subject..." onFocus="main.subject.value='';"></td>
			</tr>
			<tr>
				<td><textarea name="message" style="width: 390; height: 200;"></textarea></td>
			</tr>
			<tr>
				<td align="right" width="390"><input type="image" src="images/buttonSendMessage.gif" style="border: none;" alt="Send Message"></td>
			</tr>
			</table>
			</form>
			<? } ?>
			
			<div class="spacer2" style="height: 400px;"></div>
		</div>
		
	</div>
<? include("includes/footer.php"); ?>